{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1c399e85",
   "metadata": {},
   "outputs": [],
   "source": [
    "import k3d\n",
    "import math\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c5898675",
   "metadata": {},
   "outputs": [],
   "source": [
    "def generate(a, b, c, d, N=1000):\n",
    "    points = np.zeros(N * 3, dtype=np.float32)\n",
    "\n",
    "    x = y = z = 0\n",
    "\n",
    "    for i in range(N):\n",
    "        xn = math.sin(a * y) + c * math.cos(a * x)\n",
    "        yn = math.sin(b * x) + d * math.cos(b * y)\n",
    "        zn = math.sin(1.4 * (x + z))\n",
    "\n",
    "        points[i * 3] = xn\n",
    "        points[i * 3 + 1] = yn\n",
    "        points[i * 3 + 2] = zn\n",
    "\n",
    "        x = xn\n",
    "        y = yn\n",
    "        z = zn\n",
    "    \n",
    "    return points"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "476c9a32",
   "metadata": {},
   "outputs": [],
   "source": [
    "plot = k3d.plot()\n",
    "\n",
    "for idx in range(5):\n",
    "    p = generate(1.5 + idx * 0.1, -1.8, 1.6, 0.9)\n",
    "\n",
    "    g = \"Variant %d\" % (idx + 1)\n",
    "    plot += k3d.points(p, point_size=0.05, name='points', color=k3d.nice_colors[idx], group=g)\n",
    "    plot += k3d.line(p, name='trajectory', color=k3d.nice_colors[idx], group=g)\n",
    "\n",
    "plot.display()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bdc28fcd",
   "metadata": {},
   "outputs": [],
   "source": [
    "plot.objects[0].name = 'abc'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "385a58d8",
   "metadata": {},
   "outputs": [],
   "source": [
    "plot.objects[0].group = 'Test'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7a5c3d39",
   "metadata": {},
   "outputs": [],
   "source": [
    "plot.objects[1].group = 'Test'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d436d8eb",
   "metadata": {},
   "outputs": [],
   "source": [
    "# back to without group mode\n",
    "plot.objects[0].group = None\n",
    "plot.objects[1].group = None"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "78bc8be4",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
